Skip to content

fix(editor): rename reserved keyword methods in MarkdownManager#21

Open
alyssonbarrera wants to merge 1 commit into
novincode:mainfrom
alyssonbarrera:fix/markdown-reserved-keyword-methods
Open

fix(editor): rename reserved keyword methods in MarkdownManager#21
alyssonbarrera wants to merge 1 commit into
novincode:mainfrom
alyssonbarrera:fix/markdown-reserved-keyword-methods

Conversation

@alyssonbarrera

@alyssonbarrera alyssonbarrera commented Jun 27, 2026

Copy link
Copy Markdown

Problem

MarkdownManager uses export and import as method names. These are reserved JavaScript keywords. When Vite pre-bundles @lexkit/editor with esbuild, the method names are kept literally in the output. Safari's parser rejects this with:

SyntaxError: Unexpected token '('. Expected a ')' or a ',' after a parameter declaration.

This makes the library unusable in Safari when consumed via Vite.

Fixes #20

Fix

Rename the two private methods on MarkdownManager:

  • export()toMarkdown()
  • import()fromMarkdown()

The public API (exportToMarkdown and importFromMarkdown commands exposed via getCommands) is unchanged.

Demo

Without fix - Safari throws SyntaxError, editor fails to load:

error-demonstration.mov

With fix - editor loads and works correctly in Safari:

success-demonstration.mov

Testing

  • All 20 existing tests pass (pnpm --filter @lexkit/editor test)
  • Verified broken bundle contains literal export() / .import( before fix
  • Verified fixed bundle contains zero occurrences of reserved method names
  • Tested apps/web (Next.js) with pnpm --filter web dev - no regressions
  • Tested with a minimal Vite + React app in Safari - loads correctly after fix

`export` and `import` are reserved JavaScript keywords. Using them as
method names in a class causes a SyntaxError in Safari when Vite
pre-bundles the file with esbuild, because esbuild keeps the literal
method names and Safari's parser rejects them.

Rename `MarkdownManager#export` → `toMarkdown` and
`MarkdownManager#import` → `fromMarkdown` to fix cross-browser
compatibility without changing any public API.

Fixes novincode#20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SyntaxError when using with Vite — import and export as class method names

1 participant